<include file="header"/>
<div class="wraper space">
    <div class="list-info status">
		<if condition="$isPicked eq 0">
			<a href="#" class="iconfont icon-zuozuo pull-left" style="width: 25%" onclick="history.go(-1)"></a>
		<else />
			<a href="/base/store/order/store_id/{BEESCRM:$storeId}/order_id/{BEESCRM:$orderId}" class="iconfont icon-zuozuo pull-left" style="width: 25%" ></a>
		</if>
		<p class="text-center pull-left"  style="width: 50%">提货单</p>
		<span class="pull-right text-right" style="width: 25%"><span id="package_num">{BEESCRM:$unPicked}</span>个未领</span>
		<input type="hidden" value="{BEESCRM:$sinceId}" id="since_id">
		<input type="hidden" value="{BEESCRM:$orderId}" id="order_id">
		<input type="hidden" value="{BEESCRM:$storeId}" id="store_id">
		<input type="hidden" value="{BEESCRM:$isPicked}" id="is_picked">
	</div>
	<div class="auto-tab">
		<ul class="tab clearfix">
			<volist name="addressArr" id="vo">
				<li class="tab-list" id="tab-list-{BEESCRM:$vo['since_id']}">
					<a href="{BEESCRM::U('base/store/billOfLading',array('store_id'=>$storeId,'origin'=>$origin,'order_id'=>$orderId,'since_id'=>$vo['since_id']))}">包裹{BEESCRM:$key+1}</a>
				</li>
			</volist>
		</ul>
	</div>


	<div class="list">
		<if condition="$isPicked eq 0">
			<p class="text-center" id="address">请前往【{BEESCRM:$sinceAddress}】取货</p>
			<p class="qrimg">
				<img src="{BEESCRM::U('base/store/createOrderQrcode', array('store_id'=>$storeId, 'order_id'=>$orderId, 'since_id'=>$sinceId))}"/>
			</p>
			<p class="text-center" id="remind">凭上方二维码到提货地点提货</p>
		<else/>
			<p class="text-center">您已领取该包裹</p>
			<p class="qrimg"><img src="/assets/store/common/images/yitiqu.png"/></p>
		</if>
	</div>
	<div class="order-list">
		<volist name="data['StoreOrderGoods']" id="vo">
			<a href="{BEESCRM::U('base/store/goodsDetail',array('store_id'=>$storeId,'goods_id'=>$vo['goods_id']))}" class="list-info order text-black">
				<div class="tb-cell product-img">
					<div><img src="{BEESCRM:$vo.goods_thumb}"></div>
				</div>
				<div class="product-info">
					<p>{BEESCRM:$vo.goods_name}</p>
					<p class="text-12 prize">
						<if condition="$vo.picked eq 0">
							<span class="product-label">快递</span>
							<else/>
							<span class="product-label">自提</span>
						</if>
						<if condition="$browser eq 2">
							<if condition="$vo.pay_alipay_id neq $alipayId">
								<span class="product-label">厂家直营</span>
							</if>
						<else />
							<if condition="$vo.pay_wechat_id neq $wechatId">
								<span class="product-label">厂家直营</span>
							</if>
						</if>
					</p>
					<p class="prize"><span>￥{BEESCRM:$vo.goods_price}</span> <span>X{BEESCRM:$vo.goods_num}</span></p>
					<if condition="$vo['spec'] neq ''">
						<p>规格：{BEESCRM:$vo.spec}</p>
					</if>
				</div>
			</a>
		</volist>
	</div>
	<div class="list">
		<p class="text-right">
			共 <span class="strong-red">{BEESCRM:$data.StoreOrderGoods|count}</span> 件商品 &nbsp;&nbsp;&nbsp;
			优惠：<span class="strong-red">￥{BEESCRM:$data.discount}</span>
		</p>
		<p class="text-right">
			合计：<span class="strong-red">￥{BEESCRM:$data.order_amount}</span></p>
	</div>
	<!-- <div class="btn-box bottom">
        <p><span class="account">合计：<span>￥{BEESCRM:$data.order_amount}</span></span></p>
        <a href="#" class="btn">取消订单</a>
        <a href="#" class="btn pay">确认付款</a>
    </div> -->
</div>
<include file="commonJs" />
<script type="text/javascript">
	function goback(){
		setTimeout('location.href=document.referrer',3000);
	}
	var total = 0;
	var window_w = $(window).width();
	var tab_length = $('.tab-list').length;
	for(var i=0;i < tab_length;i++){
		var list_w = $('.tab-list').eq(i).outerWidth();
		total += list_w;
	}

	if(total>window_w){
		$('.auto-tab').addClass('tab-scroll');
		$('.auto-tab .tab').css('width',total);
	}else{
		if(tab_length==1){
			$('.auto-tab').addClass('tab-one');
		}else if(tab_length==2){
			$('.auto-tab').addClass('tab-two');
		}else if(tab_length==3) {
		$('.auto-tab').addClass('tab-three');
		}else if(tab_length==4){
			$('.auto-tab').addClass('tab-fore');
		}else if(tab_length==5){
			$('.auto-tab').addClass('tab-five');
		}
	}

	var since_id = $('#since_id').val();
	$('#tab-list-'+since_id).addClass('visited');

	//重复执行某个方法
	var is_picked = $('#is_picked').val();
	if (is_picked != 1) {
		var t = window.setInterval("reloadQrcode()", 10000);
	}

	function reloadQrcode()
	{
		$.ajax({
			url: '/base/store/reloadQrcode',
			type: 'POST',
			data: {'store_id': $('#store_id').val(),'order_id': $('#order_id').val(),'since_id': $('#since_id').val()},
			dataType: 'json',
			success:function (data) {
				if (data.is_picked == 1) {
					$('#package_num').text($('#package_num').text() * 1 - 1);
					$('.list .qrimg img').attr('src', '/assets/store/common/images/yitiqu.png');
					$('.list #address').text('您已领取该包裹');
					$('.list #remind').remove();
					//去掉定时器的方法
					window.clearInterval(t);
				}
			}
		});
	}
</script>
<include file="footer" />